<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div id="app">
      <p v-for="(ined,id) in shuzu">
        {{ined}}<button @click="txt1(id)">删除</button>
      </p>
      <button @click="txt2">生成</button>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        //定义属性
        data: {
          shuzu: [1, 5, 7, 8],
        },
        //定义方法
        methods: {
          txt1(id) {
            this.shuzu.splice(id, 1);
          },
          txt2() {
            let shu = Math.floor(Math.random() * 20);
            this.shuzu.push(shu);
          },
        },
      });
    </script>
  </body>
</html>
